////NTLM
//// http://davenport.sourceforge.net/ntlm.html
//// http://msdn.microsoft.com/en-us/library/windows/desktop/aa383144%28v=vs.85%29.aspx
////Base64
//// http://www.motobit.com/util/base64-decoder-encoder.asp (Tool)
//// http://lists.boost.org/Archives/boost/2010/05/166430.php
//// http://www.boost.org/doc/libs/1_46_1/libs/serialization/doc/dataflow.html
//// http://svn.chezphil.org/libpbe/trunk/include/base64.hh
//// http://svn.boost.org/svn/boost/sandbox/SOC/2009/unicode/libs/unicode/example/base64.cpp (VER)
//
//
////Bajar
////	 Boost Endian  -- http://svn.boost.org/svn/boost/sandbox/endian/
////	 Boost Unicode -- http://svn.boost.org/svn/boost/sandbox/SOC/2009/unicode
////	 Ver directorio "src/reemplazar en boost"
//
//
////Link
//	//libeay32.lib
//	//ssleay32.lib
//	//Secur32.lib
//
//
//#include <iostream>
//#include <istream>
//#include <ostream>
//#include <string>
//#include <fstream>			//TODO: remove
//#include <strstream>
//
//
//#include <boost/asio.hpp>
//
//#include "ntlm.hpp"
//#include "base64_stream.hpp"
//#include "bounded.hpp"
//
//
//#include <boost/range/istream_range.hpp>
//
//
//#include <boost/endian/integers.hpp>
//#include <boost/io/detail/bin_manip.hpp>
//#include <boost/endian/conversion2.hpp>
//#include <boost/endian/conversion.hpp>
//#include <boost/range/as_array.hpp>
//#include <boost/algorithm/string/split.hpp>
//#include <boost/algorithm/string/classification.hpp>
//#include <boost/algorithm/string/trim.hpp>
//#include <boost/lexical_cast.hpp>
//
//using boost::asio::ip::tcp;
//using namespace ntlm;
//
//struct http_test
//{
//	std::string host_;
//	std::string path_;
//	std::string http_version_;
//
//	std::string proxy_address_;
//	std::string proxy_port_;
//
//	boost::asio::io_service io_service_;
//
//	bool connected_;
//
//	tcp::socket socket_;
//
//
//	http_test()
//		: connected_(false), socket_(io_service_)
//	{
//		host_ = "www.google.com.ar";	
//		path_ = "/";
//		http_version_ = "1.1";
//
//		//proxy_address_ = "10.147.64.2";
//		//proxy_port_ = "8080"; //"http"
//
//		proxy_address_ = "127.0.0.1";
//		proxy_port_ = "9090";
//
//
//		try
//		{
//			//tcp::endpoint endpoint( boost::asio::ip::address::from_string("10.147.64.2"), 8080);
//			tcp::resolver resolver(io_service_);
//
//			//tcp::resolver::query query(argv[1], "http");
//			tcp::resolver::query query( proxy_address_, proxy_port_ );
//
//			tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
//
//			//tcp::socket socket_(io_service_);
//			boost::asio::connect(socket_, endpoint_iterator);
//
//
//			connected_ = true;
//
//		}
//		catch (std::exception& e)
//		{
//			std::cout << "Exception: " << e.what() << "\n";
//		}
//	}
//
//
//	typedef std::pair<std::string, std::string> http_header_type;
//
//	http_header_type parse_header( std::string const& header_str )
//	{
//		using boost::algorithm::split;
//		using boost::algorithm::token_compress_on;
//		using boost::algorithm::is_any_of;
//		using boost::algorithm::trim_copy;
//
//		std::vector<std::string> vec;	
//		boost::algorithm::split( vec, header_str, is_any_of(":"), token_compress_on );
//
//		return std::make_pair(vec.at(0), trim_copy( vec.at(1) ) );		//Can throw ( vector::at )
//	}
//
//	int send( boost::asio::streambuf & request )
//	{
//		try
//		{
//			//boost::asio::streambuf request;
//			//std::ostream request_stream(&request);
//			boost::asio::write(socket_, request);
//
//			boost::asio::streambuf response;
//			boost::asio::read_until(socket_, response, "\r\n");
//
//			// Check that response is OK.
//			std::istream response_stream(&response);
//			std::string http_version_response;
//			response_stream >> http_version_response;
//			unsigned int status_code;
//			response_stream >> status_code;
//			std::string status_message;
//			std::getline(response_stream, status_message);
//
//			if (!response_stream || http_version_response.substr(0, 5) != "HTTP/")
//			{
//				std::cout << "Invalid response\n";
//				return 1;
//			}
//
//			if (status_code != 200 && status_code != 407)
//			{
//				std::cout << "Response returned with status code " << status_code << "\n";
//				return 1;
//			}
//
//			boost::asio::read_until(socket_, response, "\r\n\r\n");
//			
//			std::string header_str;
//			std::size_t content_length = 0;
//
//			while (std::getline(response_stream, header_str) && header_str != "\r")
//			{
//				std::cout << header_str << "\n";
//
//				http_header_type header = parse_header(header_str);
//
//				if ( header.first == "Content-Length" )
//				{
//					content_length = boost::lexical_cast<std::size_t>(header.second);
//				}
//				
//			}
//
//			std::cout << "\n";
//
//
//			//auto xxx = response.size();
//
//			// Write whatever content we already have to output.
//			if (response.size() > 0)
//			{
//				std::cout << &response;
//			}
//
//			std::size_t remaining = content_length - response.size();
//
//			// Read until EOF, writing data to output as we go.
//			boost::system::error_code error;
//			if ( boost::asio::read(socket_, response, boost::asio::transfer_at_least(remaining), error) )
//			{
//				std::cout << &response;
//			}
//
//			//if ( boost::asio::read(socket_, response, boost::asio::transfer_at_least(1), error) )
//			//{
//			//	std::cout << &response;
//			//	//remaining -= response.size();
//			//}
//
//			//if (error != boost::asio::error::eof)
//			//{
//			//	throw boost::system::system_error(error);
//			//}
//		}
//		catch (std::exception& e)
//		{
//			std::cout << "Exception: " << e.what() << "\n";
//		}
//	}
//
//
//	void step_old_0()
//	{
//		//request_stream << "GET " << path << " HTTP/" << http_version << "\r\n";
//		//request_stream << "Host: " << host << "\r\n";
//		//request_stream << "Accept: */*\r\n";
//		//request_stream << "Connection: close\r\n";
//		//request_stream << "\r\n";
//	}
//
//
//	//Message without authentication
//	void step1()
//	{
//		boost::asio::streambuf request;
//		std::ostream request_stream(&request);
//
//		//Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
//		//Accept-Language: es-AR
//		//User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2)
//		//Accept-Encoding: gzip, deflate
//		//Proxy-Connection: Keep-Alive
//		//Host: www.google.com
//		//Cookie: PREF=ID=95f129ae48a27026:U=f417ab71a4b80412:FF=0:TM=1313506129:LM=1313590779:S=MqTcUdUawVWmf4Hl; NID=51=lwbE_jekFZ13HvMAtxyibXG16M7uukjbi5w7sOOoHcL4WiQL-lSulpnYJQtSF58SOZvFrZPL4r7FSP1IXAPB75UoWCg23YpJ8hp45toWsUeYAx0Tpb-TNJf4Mkwkcscm
//	
//		request_stream << "GET " << "http://www.google.com.ar/" << " HTTP/" << http_version_ << "\r\n";
//		request_stream << "Proxy-Connection: Keep-Alive" << "\r\n";
//		request_stream << "Host: " << host_ << "\r\n";
//		request_stream << "\r\n";
//
//
//		send(request);
//
//		//Response-----------------------------------------
//		//Via: 1.1 WARGTY01
//		//Proxy-Authenticate: Negotiate
//		//Proxy-Authenticate: Kerberos
//		//Proxy-Authenticate: NTLM
//		//Connection: Keep-Alive
//		//Proxy-Connection: Keep-Alive
//		//Pragma: no-cache
//		//Cache-Control: no-cache
//		//Content-Type: text/html
//		//Content-Length: 4127
//
//
//	}
//
//	void step2()
//	{
//		boost::asio::streambuf request;
//		std::ostream request_stream(&request);
//
//		message<type1> gm1 = make_from_system<type1>();
//
//
//		//GET http://www.google.com/search?hl=es&q=123&lr= HTTP/1.1
//		//Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
//		//Accept-Language: es-AR
//		//User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2)
//		//Accept-Encoding: gzip, deflate
//		//Proxy-Connection: Keep-Alive
//		//Cookie: PREF=ID=95f129ae48a27026:U=f417ab71a4b80412:FF=0:TM=1313506129:LM=1313590779:S=MqTcUdUawVWmf4Hl; NID=51=lwbE_jekFZ13HvMAtxyibXG16M7uukjbi5w7sOOoHcL4WiQL-lSulpnYJQtSF58SOZvFrZPL4r7FSP1IXAPB75UoWCg23YpJ8hp45toWsUeYAx0Tpb-TNJf4Mkwkcscm
//		//Proxy-Authorization: Negotiate TlRMTVNTUAABAAAAl7II4gYABgAzAAAACwALACgAAAAGAbEdAAAAD1BST0ctRlJBLTMxQ0RTLUJB
//		//Host: www.google.com
//	
//		request_stream << "GET " << "http://www.google.com.ar/" << " HTTP/" << http_version_ << "\r\n";
//		request_stream << "Proxy-Connection: Keep-Alive" << "\r\n";
//		request_stream << "Proxy-Authorization: Negotiate " << (base64_stream() << gm1) << "\r\n";
//		request_stream << "Host: " << host_ << "\r\n";
//		request_stream << "\r\n";
//
//
//		send(request);
//
//
//
//		//Response returned with status code 407
//		//Via: 1.1 WARGTY01
//		//Proxy-Authenticate: Negotiate TlRMTVNTUAACAAAADAAMADgAAAAVgonilcj4Ud4XZCoAAAAAAAAAAJoAmgBEAAAABgGxHQAAAA9DAEQAUwAtAEIAQQACAAwAQwBEAFMALQBCAE
//		//EAAQAQAFcAQQBSAEcAVABZADAAMQAEABgAYwBkAHMALQBiAGEALgBsAG8AYwBhAGwAAwAqAFcAQQBSAEcAVABZADAAMQAuAGMAZABzAC0AYgBhAC4AbABvAGMAYQBsAAUAGABjAGQAcw
//		//AtAGIAYQAuAGwAbwBjAGEAbAAHAAgAx6Se+fGBzAEAAAAA
//		//Connection: Keep-Alive
//		//Proxy-Connection: Keep-Alive
//		//Pragma: no-cache
//		//Cache-Control: no-cache
//		//Content-Type: text/html
//		//Content-Length: 0
//
//
//
//		//Response returned with status code 407
//		//Via: 1.1 WARGTY01
//		//Proxy-Authenticate: Negotiate TlRMTVNTUAACAAAADAAMADgAAAAVgonilF0OzUFZroUAAAAAAA
//		//AAAJoAmgBEAAAABgGxHQAAAA9DAEQAUwAtAEIAQQACAAwAQwBEAFMALQBCAEEAAQAQAFcAQQBSAEcAVA
//		//BZADAAMQAEABgAYwBkAHMALQBiAGEALgBsAG8AYwBhAGwAAwAqAFcAQQBSAEcAVABZADAAMQAuAGMAZA
//		//BzAC0AYgBhAC4AbABvAGMAYQBsAAUAGABjAGQAcwAtAGIAYQAuAGwAbwBjAGEAbAAHAAgAomXEjHCSzA
//		//EAAAAA
//		//Connection: Keep-Alive
//		//Proxy-Connection: Keep-Alive
//		//Pragma: no-cache
//		//Cache-Control: no-cache
//		//Content-Type: text/html
//		//Content-Length: 0
//
//
//
//
//
//
//	}
//
//
//	//request_stream << "Authorization: NTLM TlRMTVNTUAABAAAAA7IAAAoACgApAAAACQAJACAAAABMSUdIVENJVFlVUlNBLU1JTk9S\r\n";			//TODO:
//	//request_stream << "Proxy-Authorization: Negotiate TlRMTVNTUAABAAAAl7II4gYABgAzAAAACwALACgAAAAGAbEdAAAAD1BST0ctRlJBLTMxQ0RTLUJB" << "\r\n";
//
//
//	//unsigned char temp[] = { 0x4e  ,0x54 ,0x4c ,0x4d ,0x53 ,0x53 ,0x50 ,0x00 ,0x01 ,0x00 ,0x00 ,0x00 ,0x07 ,0x32 ,0x00 ,0x00, 0x0c ,0x00 ,0x0c ,0x00 ,0x24 ,0x00 ,0x00 ,0x00 ,0x0b ,0x00 ,0x0b ,0x00 ,0x30 ,0x00 ,0x00 ,0x00, 0x06 ,0x01 ,0xb1 ,0x1d ,0x00 ,0x00 ,0x00 ,0x0f ,0x43 ,0x44 ,0x53 ,0x2d ,0x42 ,0x41 ,0x2e ,0x4c, 0x4f ,0x43 ,0x41 ,0x4c ,0x50 ,0x52 ,0x4f ,0x47 ,0x2d ,0x46 ,0x52 ,0x41 ,0x2d ,0x33 ,0x31 };
//	////unsigned char temp[] = { 0x01, 0xb1, 0x1d  };
//
//	//std::ofstream myfile ("output_text.dat");
//	//if ( myfile.is_open() )
//	//{
//	//	//myfile << gm1 << std::endl;
//	//	myfile << boost::bin( temp ) << std::endl;
//	//	myfile.close();
//	//}
//	//
//	////std::cout << (base64_stream() << gm1) << std::endl << std::endl;
//
//	//std::stringstream ss;
//
//	//using boost::base64_encoder;
//	//using boost::base64_decoder;
//	//using boost::adaptors::converted;
//
//	//boost::copy( temp | converted(base64_encoder()), std::ostream_iterator<char>(std::cout) );
//	//std::cout << std::endl;
//	//std::cout << std::endl;
//
//	//boost::copy( temp | converted(base64_encoder()), std::ostream_iterator<char>(ss) );
//	//std::string temp2 = ss.str();
//
//	//std::cout << (base64_stream() << gm1);
//	//std::cout << std::endl;
//	//std::cout << std::endl;
//
//	void step3()
//	{
//		boost::asio::streambuf request;
//		std::ostream request_stream(&request);
//
//		//GET http://www.google.com/search?hl=es&q=123&lr= HTTP/1.1
//		//Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
//		//Accept-Language: es-AR
//		//User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2)
//		//Accept-Encoding: gzip, deflate
//		//Proxy-Connection: Keep-Alive
//		//Cookie: PREF=ID=95f129ae48a27026:U=f417ab71a4b80412:FF=0:TM=1313506129:LM=1313590779:S=MqTcUdUawVWmf4Hl; NID=51=lwbE_jekFZ13HvMAtxyibXG16M7uukjbi5w7sOOoHcL4WiQL-lSulpnYJQtSF58SOZvFrZPL4r7FSP1IXAPB75UoWCg23YpJ8hp45toWsUeYAx0Tpb-TNJf4Mkwkcscm
//		//Host: www.google.com
//		//Proxy-Authorization: Negotiate TlRMTVNTUAADAAAAGAAYAKIAAAA+AT4BugAAAAwADABYAAAAKAAoAGQAAAAWABYAjAAAABAAEAD4AQAAFYKI4gYBsR0AAAAPy72xJaOjXE2Rr5LIM+1luUMARABTAC0AQgBBAEYAZQByAG4AYQBuAGQAbwAuAFAAZQBsAGwAaQBjAGMAaQBvAG4AaQBQAFIATwBHAC0ARgBSAEEALQAzADEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKRmooE1Q3W7tOvV84UALuQEBAAAAAAAAF3tYjtyBzAG104wK5Ak3vQAAAAACAAwAQwBEAFMALQBCAEEAAQAQAFcAQQBSAEcAVABZADAAMQAEABgAYwBkAHMALQBiAGEALgBsAG8AYwBhAGwAAwAqAFcAQQBSAEcAVABZADAAMQAuAGMAZABzAC0AYgBhAC4AbABvAGMAYQBsAAUAGABjAGQAcwAtAGIAYQAuAGwAbwBjAGEAbAAHAAgAF3tYjtyBzAEGAAQAAgAAAAgAMAAwAAAAAAAAAAAAAAAAMAAAMuDHhWGrtMlumrjuhPLFjWz3nL//clg/Ac3TAlb47hkKABAAAAAAAAAAAAAAAAAAAAAAAAkAHABIAFQAVABQAC8AMQAyADcALgAwAC4AMAAuADEAAAAAAAAAAAAAAAAAtEBJtuOZ/iNIPu1YYzoorQ==
//
//
//		request_stream << "GET " << "http://www.google.com.ar/" << " HTTP/" << http_version_ << "\r\n";
//		//request_stream << "Authorization: NTLM TlRMTVNTUAABAAAAA7IAAAoACgApAAAACQAJACAAAABMSUdIVENJVFlVUlNBLU1JTk9S\r\n";			//TODO:
//		request_stream << "Proxy-Connection: Keep-Alive" << "\r\n";
//		request_stream << "Proxy-Authorization: Negotiate TlRMTVNTUAADAAAAGAAYAKIAAAA+AT4BugAAAAwADABYAAAAKAAoAGQAAAAWABYAjAAAABAAEAD4AQAAFYKI4gYBsR0AAAAPy72xJaOjXE2Rr5LIM+1luUMARABTAC0AQgBBAEYAZQByAG4AYQBuAGQAbwAuAFAAZQBsAGwAaQBjAGMAaQBvAG4AaQBQAFIATwBHAC0ARgBSAEEALQAzADEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKRmooE1Q3W7tOvV84UALuQEBAAAAAAAAF3tYjtyBzAG104wK5Ak3vQAAAAACAAwAQwBEAFMALQBCAEEAAQAQAFcAQQBSAEcAVABZADAAMQAEABgAYwBkAHMALQBiAGEALgBsAG8AYwBhAGwAAwAqAFcAQQBSAEcAVABZADAAMQAuAGMAZABzAC0AYgBhAC4AbABvAGMAYQBsAAUAGABjAGQAcwAtAGIAYQAuAGwAbwBjAGEAbAAHAAgAF3tYjtyBzAEGAAQAAgAAAAgAMAAwAAAAAAAAAAAAAAAAMAAAMuDHhWGrtMlumrjuhPLFjWz3nL//clg/Ac3TAlb47hkKABAAAAAAAAAAAAAAAAAAAAAAAAkAHABIAFQAVABQAC8AMQAyADcALgAwAC4AMAAuADEAAAAAAAAAAAAAAAAAtEBJtuOZ/iNIPu1YYzoorQ==" << "\r\n";
//		request_stream << "Host: " << host_ << "\r\n";
//		request_stream << "\r\n";
//
//
//		send(request);
//	}
//
//};
//
//
//
//////------------------------------------------------------------------------------------------------------------------------------------
//
//
//int main(int argc, char* argv[])
//{
//	//auto xxx0 = detail::get_domain_name();
//	//auto xxx1 = detail::get_computer_name(ComputerNameNetBIOS);
//	//auto xxx2 = detail::get_computer_name(ComputerNamePhysicalNetBIOS);
//	//auto xxx3 = detail::get_computer_name(ComputerNamePhysicalDnsFullyQualified);
//	//auto xxx4 = detail::get_computer_name(ComputerNamePhysicalDnsDomain);
//	//auto xxx5 = detail::get_user_domain_name();
//
//
//
//	http_test test;
//	test.step1();
//	test.step2();
//	test.step3();
//
//	return 0;
//}
//
//
//////------------------------------------------------------------------------------------------------------------------------------------
////typedef std::pair<int, std::string> vec_element_t;
////typedef std::vector<vec_element_t> flag_vector_t;
////flag_vector_t fvec;
////
////
////template <typename T, typename U>
////inline bool flag_enabled( T flags, U query )
////{
////	return ( (flags & query) == query );
////}
////
////
////void print_flags( boost::uint32_t flags )
////{
////	auto it = fvec.begin();
////	auto end = fvec.end();
////
////	for ( ; it != end; ++it )
////	{
////		auto flag = (*it).first;
////
////		if ( flag_enabled (flags, flag) )
////		{
////			auto message = (*it).second;
////			std::cout << message << std::endl;
////		}
////	}
////
////}
////
////
////
////int main(int argc, char* argv[])
////{
////	fvec.push_back( std::make_pair(flags::negotiate_unicode, "negotiate_unicode") );
////	fvec.push_back( std::make_pair(flags::negotiate_oem, "negotiate_oem") );
////	fvec.push_back( std::make_pair(flags::request_target, "request_target") );
////	fvec.push_back( std::make_pair(flags::negotiate_ntlm, "negotiate_ntlm") );
////	fvec.push_back( std::make_pair(flags::negotiate_domain_supplied, "negotiate_domain_supplied") );
////	fvec.push_back( std::make_pair(flags::negotiate_workstation_supplied, "negotiate_workstation_supplied") );
////	fvec.push_back( std::make_pair(flags::negotiate_always_sign, "negotiate_always_sign") );
////	fvec.push_back( std::make_pair(flags::negotiate_ntlm2_key, "negotiate_ntlm2_key") );
////	fvec.push_back( std::make_pair(flags::negotiate_128, "negotiate_128") );
////	fvec.push_back( std::make_pair(flags::negotiate_56, "negotiate_56") );
////
////
////	boost::uint32_t flags = 0xe208b2b7;
////	print_flags(flags);
////
////
////
////	//Negotiate Unicode (0x00000001) 	The client sets this flag to indicate that it supports Unicode strings.
////	//Negotiate OEM (0x00000002) 	This is set to indicate that the client supports OEM strings.
////	//Request Target (0x00000004) 	This requests that the server send the authentication target with the Type 2 reply.
////	//Negotiate NTLM (0x00000200) 	Indicates that NTLM authentication is supported.
////	//Negotiate Domain Supplied (0x00001000) 	When set, the client will send with the message the name of the domain in which the workstation has membership.
////	//Negotiate Workstation Supplied (0x00002000) 	Indicates that the client is sending its workstation name with the message.
////	//Negotiate Always Sign (0x00008000) 	Indicates that communication between the client and server after authentication should carry a "dummy" signature.
////	//Negotiate NTLM2 Key (0x00080000) 	Indicates that this client supports the NTLM2 signing and sealing scheme; if negotiated, this can also affect the response calculations.
////	//Negotiate 128 (0x20000000) 	Indicates that this client supports strong (128-bit) encryption.
////	//Negotiate 56 (0x80000000) 	Indicates that this client supports medium (56-bit) encryption. 
////
////
////	return 0;
////}
//
//
//
//
//
//
//
//
//////------------------------------------------------------------------------------------------------------------------------------------
//
//
//
////template <typename T, typename U>
////inline bool flag_enabled( T flags, U query )
////{
////	return ( (flags & query) == query );
////}
////
////
////
////struct istremable
////{
////	friend std::istream& operator>>( std::istream & istr, istremable & obj )
////	{
////		using boost::bin;
////		using boost::endian2::little;
////		using boost::endian::little_to_native;
////		using boost::adaptors::bounded;
////
////		boost::uint32_t temp32;
////		char header[8];
////		boost::uint32_t type;
////		char challenge[8];
////		char context[8];
////		boost::uint32_t flags;
////		security_buffer target_name_sb;
////		security_buffer target_information_sb;
////		os_version osv;
////
////		std::istream::pos_type data_offset;
////
////
////
////		std::string target_name;
////
////		istr.readsome(header, 8);																// 8
////
////		//istr >> bin( little(type) );		//Error
////		istr >> bin( temp32 );																	// 4
////		little_to_native(temp32, type);
////
////		istr >> target_name_sb;																	// 8
////		data_offset = target_name_sb.offset;
////
////
////		istr >> bin( temp32 );																	// 4
////		little_to_native(temp32, flags);
////
////		istr.readsome(challenge, 8);															// 8
////
////
////		// Optional data ---
////
////		if ( data_offset != istr.tellg() ) 
////		{
////			//if ( flag_enabled (flags, flags::negotiate_local_call) )
////			//{
////			istr.readsome(context, 8);															// 8
////			//}
////		}
////
////		if ( data_offset != istr.tellg() ) 
////		{
////			if ( flag_enabled (flags, flags::negotiate_target_info) )
////			{
////				istr >> target_information_sb;														// 8
////
////				if ( target_information_sb.offset != 0 && target_information_sb.offset < data_offset )
////				{
////					data_offset = target_information_sb.offset;
////				}
////			}
////		}
////
////		if ( data_offset != istr.tellg() ) 
////		{
////			istr >> osv;																			// 8
////		}
////
////
////		//Data section ---
////
////		if ( target_name_sb.length > 0 )
////		{
////			target_name.reserve( target_name_sb.length );
////			auto rng = boost::istream_range<char>(istr);
////			boost::copy( rng | bounded(target_name_sb.length), std::back_inserter<std::string>(target_name) );
////		}
////
////
////
////		return istr;
////	}
////};
//
////template <typename T>
////struct dyn_array
////{
////	template <std::size_t sz>
////	dyn_array( const T (&static_array)[sz] )
////		: size_( sz ), array_( new T[sz] )
////	{
////		//array_ = new T[sz];
////		std::memcpy( array_, static_array, sz );
////	}
////
////	~dyn_array()
////	{
////		delete[] array_;	
////	}
////
////	std::size_t size_;
////	T* array_;
////};
//
//
//
//
//
//////boost::iterator_range<char*>& operator>>( boost::iterator_range<char*> & istr, boost::uint32_t & val ) 
//////{
//////	val = reinterpret_cast<boost::uint32_t>( boost::begin(istr)  );
//////	return boost::iterator_range<char*>( boost::begin(istr) + sizeof(boost::uint32_t), boost::end(istr) );
//////}
//////
//////template <typename SinglePassRange >
//////void process_binary( SinglePassRange & range )
//////{
//////	using boost::bin;
//////	using boost::endian2::little;
//////	using boost::endian::little_to_native;
//////
//////	char header[8];
//////	char challenge[8];
//////	char context[8];
//////	boost::uint32_t temp32;
//////	boost::uint32_t type;
//////	boost::uint32_t flags;
//////	security_buffer target_name_sb;
//////	security_buffer target_information_sb;
//////	os_version osv;
//////	 
//////	range >> temp32;
//////
//////}
////
////
//////template <typename T, std::size_t sz>
//////inline void allocate_copy_array( const T (&static_array)[sz], T* & dynamic_array )
//////{
//////	dynamic_array = new char[sz];
//////	std::memcpy( dynamic_array, static_array, sz );
//////}
//
//
//
////
////int main(int argc, char* argv[])
////{
////	using boost::base64_encoder;
////	using boost::base64_decoder;
////	using boost::adaptors::converted;
////
////
////	//---------------------------------------------------------------------------------------------------------------------
////
////
////	std::stringstream in_stream;
////	in_stream << "TlRMTVNTUAACAAAADAAMADgAAAAVgonilcj4Ud4XZCoAAAAAAAAAAJoAmgBEAAAABgGxHQAAAA9DAEQAUwAtAEIAQQACAAwAQwBEAFMALQBCAEEAAQAQAFcAQQBSAEcAVABZADAAMQAEABgAYwBkAHMALQBiAGEALgBsAG8AYwBhAGwAAwAqAFcAQQBSAEcAVABZADAAMQAuAGMAZABzAC0AYgBhAC4AbABvAGMAYQBsAAUAGABjAGQAcwAtAGIAYQAuAGwAbwBjAGEAbAAHAAgAx6Se+fGBzAEAAAAA";
////
////
////	////std::string temp;
////	////in_stream >> temp;
////
////	////std::string decoded;
////	////boost::copy( decoded | converted(base64_decoder()), std::back_inserter(decoded) );
////
////	////istream_range<char>(in_stream)
////
////	////std::istream_iterator<char> eos;         
////	////std::istream_iterator<char> iit (in_stream);
////
////	////for ( ;iit != eos; ++iit )
////	////{
////	////	std::cout << *iit;
////	////}
////
////
////	////auto range = boost::istream_range<char>(in_stream);
////	////auto iit = boost::begin(range);
////	////auto eos = boost::end(range);
////
////	////for ( ;iit != eos; ++iit )
////	////{
////	////	std::cout << *iit;
////	////}
////
////	//	//boost::copy( boost::istream_range<char>(in_stream) ,
////	//	//			std::ostream_iterator<char>(std::cout) 
////	//	//  		);
////
////
////	////std::ofstream myfile ("output_text.dat");
////	////if ( myfile.is_open() )
////	////{
////	////		boost::copy( boost::istream_range<char>(in_stream) | converted(base64_decoder()),
////	////					std::ostream_iterator<char>(myfile)
////	////	  			);
////
////	////	myfile.close();
////	////}
////
////
////	//istremable x;
////	//base64_stream bs;
////	//in_stream >> bs;
////	//bs >> x;
////
////	//---------------------------------------------------------------------------------------------------------------------
////
////
////
////
////
////
////	//---------------------------------------------------------------------------------------------------------------------
////	char bin_data[] = {	0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x02, 0x81, 0x00
////		,0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, 0x62, 0x00, 0x3c, 0x00, 0x00, 0x00
////		,0x44, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x41, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x44, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x41, 0x00
////		,0x49, 0x00, 0x4e, 0x00, 0x01, 0x00, 0x0c, 0x00, 0x53, 0x00, 0x45, 0x00, 0x52, 0x00, 0x56, 0x00, 0x45, 0x00, 0x52, 0x00, 0x04, 0x00, 0x14, 0x00
////		,0x64, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x03, 0x00, 0x22, 0x00
////		,0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x2e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x69, 0x00
////		,0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00 };
////
////
////	dyn_array<char> dyn_bin_data ( bin_data );
////
////	std::cout << dyn_bin_data.size_ << std::endl;
////
////	istremable x;
////
////	std::istrstream temp( dyn_bin_data.array_,  dyn_bin_data.size_ );
////	temp >> x;
////
////
////
////	//delete[] dyn_bin_data;
////	//---------------------------------------------------------------------------------------------------------------------
////
////	return 0;
////}
//
//
//
//
//
//////------------------------------------------------------------------------------------------------------------------------------------
////#include <iostream>
////#include <vector>
////#include <boost/assign.hpp>
////#include <boost/range/adaptors.hpp>
////
////int main()
////{
////	using namespace boost::adaptors;
////	using namespace boost::assign;
////
////	std::vector<int> input;
////	input += 0,1,1,2,3,5,8,13,21,34,55;
////
////	auto it = boost::begin(input);
////	auto end = boost::end(input);
////	const int N = 9;
////
////	for ( int i=0; it != end && i<N; ++it, ++i )
////	{
////		std::cout << *it << ',';
////	}
////}
//////------------------------------------------------------------------------------------------------------------------------------------